
<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>值班加班选择</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="__ROOT__/static/plugs/layui/css/layui.css?at=0217">
    <link rel="stylesheet" href="__ROOT__/static/plugs/layui/css/xadmin.css">
    <script type="text/javascript" src="__ROOT__/static/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="__ROOT__/static/plugs/layui/layui.all.js" charset="utf-8"></script>

  </head>
  <body>

    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md3 x-so">
          <input type="text" name="name"  placeholder="请输入用户名" value="{$Think.get.name|default=''}" autocomplete="off" class="layui-input">
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <xblock>
        <!-- <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button> -->
        <!-- <span class="x-right" style="line-height:40px">共有数据：88 条</span> -->
      </xblock>
	  
      <table class="layui-table">
        <thead>
          <tr>
		  <!--
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>-->
            <th>ID</th>
            <th>姓名</th>
            <th>加班日期</th>
            <th>类型</th>
            <th>换休天数</th>
            <th>已休天数</th>
			<th><span class="layui-badge">未休天数</span></th>
			<th>点击</th>
        </thead>
        <tbody>
		{foreach $list as $key=>$vo}
          <tr>
            <!-- <td> -->
              <!-- <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$vo.id}'><i class="layui-icon">&#xe605;</i></div> -->
            <!-- </td> -->
            <td>{$vo.id}</td>
            <td>{$vo.name}</td>
			<td>{$vo.otdate}</td>
			<td>{$vo.datetype}</td>

			<td>{$vo.buxiunum}</td>
			<td>{$vo.yixiunum}</td>
			<td><span class="layui-badge">{$vo.buxiunum-$vo.yixiunum}</span></td>
            <td class="td-manage">

              <a title="选择" onclick="member_del(this,'{$vo.id}' , '{$vo.name}' , '{$vo.otdate}' ,'{$vo.datetype}' ,'{$vo.buxiunum}' ,'{$vo.yixiunum}' )" href="javascript:;">
                <i class="layui-icon">&#xe642;</i>
              </a>
			  &nbsp;&nbsp;
              <a title="废除" onclick="member_op(this,'{$vo.id}')" href="javascript:;">
                <i class="layui-icon">&#xe643;</i>
              </a>	  
			  
            </td>
          </tr>
		{/foreach}



        </tbody>
      </table>
      <div class="page">
        <div>
           {$page|raw} 
		  

		  
        </div>
      </div>

    </div>
    <script>
      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });
	  
	  function member_op(obj, id)
	  {
        $.ajax({
            //请求方式
            type : "POST",
            //请求的媒体类型
            //dataType: "JSON",
            //请求地址
            url : "{:url('changeJiaqi')}?id="+id,
            //数据，json字符串
            //data : "?id="+id,
            //请求成功
            success : function(result) {
                console.log(result);
				alert(result.msg+id);
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                console.log(e.status);
                console.log(e.responseText);
            }
        });
  
	  }
	  

       /*用户-停用*/
      function member_stop(obj,id){
          layer.confirm('确认要停用吗？',function(index){

              if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!',{icon: 5,time:1000});

              }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});
              }
              
          });
      }


      function member_del(obj,id , name , otdate ,datetype ,buxiunum ,yixiunum){
          //layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
             // $("#j_id",window.parent.document).attr("value",'6662');

		
		var id = id;
        var str = '<tr id="list">'+
                    '<td>'+
                         id +
						 '<input type="hidden" name="j_id[]" id="j_id" value="'+id+'" lay-verify="required"  class="layui-input">'+
                    '</td>'+
                    '<td>'+
                        '<input type="hidden" name="j_name[]" id="j_name" value="'+name+'" lay-verify="required"  class="layui-input">'+
                        name +
                    '</td>'+
                    '<td>'+
                        '<input type="hidden" name="j_otdate[]" id="j_otdate" value="'+otdate+'" lay-verify="required"  class="layui-input">'+
                        otdate +
                    '</td>'+
                    '<td>'+
                        datetype +
                        '<input type="hidden" name="j_datetype[]" id="j_datetype" value="'+datetype+'" lay-verify="required"  class="layui-input">'+
                    '</td>'+
                    '<td>'+
                        '<input type="hidden" name="j_buxiunum[]" id="j_buxiunum" value="'+buxiunum+'" lay-verify="required"  class="layui-input">'+
                        buxiunum +
                    '</td>'+
                    '<td>'+
                        yixiunum +
                        '<input type="hidden" name="j_yixiunum[]" id="j_yixiunum" value="'+yixiunum+'"  lay-verify="required"  class="layui-input">'+
                    '</td>'+
                    '<td>'+
                        '<input type="type" name="j_days[]" id="j_days" lay-verify="required" required pattern="^[0-9]+(.[0|5]{1})?$" class="layui-input">'+
                    '</td>'+
                    '<td>'+
                        '<a class="layui-btn layui-btn-xs" onclick="delCustomList(this)">删除</a>'+
                        //'<a class="layui-btn layui-btn-xs layui-btn-danger" onclick="x_admin_show(\'添加用户\',\'/list.html\');">选择</a>'+
                    '</td>'+
                '</tr>';
              //$("#customList").append(str);
			  
			  //οninput="this.value=this.value.replace(/^[+][0-9]+(.[0|5]{1})?$/g,\'\')"  



			  
			/*
			$('#customList #list' ,window.parent.document).each(function(i){                   // 遍历 tr
				$(this).find('td').each(function (j) {
				  //$(this).children('tr').each(function(j){  // 遍历 tr 的各个 td
				    var tdArr = $(this).children();
					//console.log(tdArr);
					//var tmp_id = tdArr.eq(0).find('input').val();//收入类别
					//var tmp_id = $(this).find('td:eq(0)').text();  //每个tr里面的第1个td
					
					var tmp_id = tdArr.eq(1).text();
					console.log(tmp_id);
					
					
					 if(id == tmp_id ){
						alert('已经选择过');
						return ;
						return false; //跳出循环					
					 }else{
						
					 }
					//console.log("第"+(i+1)+"行，第"+(j+1)+"个td的值："+$(this).text()+"。");

			   });
		   });*/
		   
		    //var buf = [];
			$('#customList tbody' ,window.parent.document).each(function(index , element){


					var a = $(element).children();
					for(var i=1;i<a.length;i++){
						//alert(a.eq(i).find('td:eq(0)').text());// 取得index为 i的td里面的文本
						var ids =a.eq(i).find('td:eq(0)').text();
						if(ids==id){
							alert(id+ '已经选择过');
							return false;
						}
					}

                    var tmp_id =(  $(this).find('td:eq(0)').text() );
					
					//console.log(  $(this)  )
					var txt = $(this).find('#list tr').find('td:eq(0)').text();  //第1个td
					var tmp_days = $(element).children().find("input[name='j_days[]']").val();//应休
					//console.log(tmp_days)
					
					if(tmp_id ==id){
						//alert('已经选择过');
						return false; //跳出循环		
					}else{
						$("#customList tbody",window.parent.document).append(str);
					}

			})
			
			//console.log(buf)
		   
		    
		   
			/*
		    $.each($('#customList>#list tr' ,window.parent.document),function (index,val) {
				var tdArr = $(this).children('td');
				var id =$(this).find('td:eq(0)').text();  //我选中的是每个tr里面的第3个td
				console.log(id);
				
			});*/
		   
			//var tdArr = $('#customList tr' ,window.parent.document).children('td');
			//var tmp_id = tdArr.eq(0).find('input').val();//收入类别
			//var tmp_id = $('#customList tr' ,window.parent.document).children('td').eq(0).text();//收入类别
			//var tmp_id = tdArr.eq(0).text();//第一列


			$("input").each(function(){
				if($(this).val()==""){
				flag=false;
				return false;
				}
			});        


              //$(obj).parents("tr").remove();
              //layer.msg('已删除!',{icon:1,time:1000});
              var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
              //parent.layer.close(index1); //再执行关闭
          //});
      }



      function delAll (argument) {

        var data = tableCheck.getData();
  
        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
      }
    </script>

</body>

</html>